<head>
    <meta charset="UTF-8">
<title>算法提高 快速排序</title>
<link rel="stylesheet" href="../css/main.css">
</head>
 <p class="MsoNormal"><b><span style="font-family:宋体;mso-ascii-font-family:Calibri;mso-hansi-font-family:Calibri">问题描述</span><span lang="EN-US"><o:p></o:p></span></b></p>
<p class="MsoNormal" style="text-indent:21.0pt"><span style="font-family:宋体;
mso-ascii-font-family:Calibri;mso-hansi-font-family:Calibri">用递归来实现快速排序（</span><span lang="EN-US">quick sort</span><span style="font-family:宋体;mso-ascii-font-family:
Calibri;mso-hansi-font-family:Calibri">）算法。快速排序算法的基本思路是：假设要对一个数组</span><span lang="EN-US">a</span><span style="font-family:宋体;mso-ascii-font-family:Calibri;
mso-hansi-font-family:Calibri">进行排序，且</span><span lang="EN-US">a[0] = x</span><span style="font-family:宋体;mso-ascii-font-family:Calibri;mso-hansi-font-family:Calibri">。首先对数组中的元素进行调整，使</span><span lang="EN-US">x</span><span style="font-family:宋体;mso-ascii-font-family:Calibri;
mso-hansi-font-family:Calibri">放在正确的位置上。同时，所有比</span><span lang="EN-US">x</span><span style="font-family:宋体;mso-ascii-font-family:Calibri;mso-hansi-font-family:Calibri">小的数都位于它的左边，所有比</span><span lang="EN-US">x</span><span style="font-family:宋体;mso-ascii-font-family:Calibri;
mso-hansi-font-family:Calibri">大的数都位于它的右边。然后对于左、右两段区域，递归地调用快速排序算法来进行排序。</span><span lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-indent:21.0pt"><span style="font-family:宋体;
mso-ascii-font-family:Calibri;mso-hansi-font-family:Calibri">输入格式：输入只有一行，包括若干个整数（不超过</span><span lang="EN-US">10</span><span style="font-family:宋体;mso-ascii-font-family:Calibri;
mso-hansi-font-family:Calibri">个），以</span><span lang="EN-US">0</span><span style="font-family:宋体;mso-ascii-font-family:Calibri;mso-hansi-font-family:Calibri">结尾。</span><span lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-indent:21.0pt"><span style="font-family:宋体;
mso-ascii-font-family:Calibri;mso-hansi-font-family:Calibri">输出格式：输出只有一行，即排序以后的结果（不包括末尾的</span><span lang="EN-US">0</span><span style="font-family:宋体;mso-ascii-font-family:Calibri;
mso-hansi-font-family:Calibri">）。</span><span lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><b><span style="font-family:宋体;mso-ascii-font-family:Calibri;mso-hansi-font-family:Calibri">输入输出样例</span><span lang="EN-US"><o:p></o:p></span></b></p>
<p class="MsoNormal" style="text-indent:21.0pt"><span style="font-family:宋体;
mso-ascii-font-family:Calibri;mso-hansi-font-family:Calibri">输入样例：</span><span lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-indent:21.0pt"><span lang="EN-US" style="font-family:&quot;Courier New&quot;">5 2 6 1 7 3 4 0<o:p></o:p></span></p>
<p class="MsoNormal" style="text-indent:21.0pt"><span style="font-family:宋体;
mso-ascii-font-family:Calibri;mso-hansi-font-family:Calibri">输出样例：</span><span lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-indent:21.0pt"><span lang="EN-US" style="font-family:&quot;Courier New&quot;">1 2 3 4 5 6 7</span><span lang="EN-US"><o:p></o:p></span></p>